Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Text
Imports System.Windows.Forms

Namespace C4F.DevKit.Speech.Controls
	''' <summary>
	''' A control used to convert speech to text.
	''' </summary>
	Public Partial Class SpeechDictation
		Inherits UserControl
		#Region "Private Data"

		Private _sapiManager As SapiManager = Nothing

		Private Const DESIGNER_CATEGORY As String = "Speech"

		#End Region ' Private Data

		#Region "Constructor"

		''' <summary>
		''' Initializes a new instance of the SpeechDictation control.
		''' </summary>
		Public Sub New()
			InitializeComponent()
		End Sub

		#End Region ' Constructor

		#Region "Properties"

		''' <summary>
		''' The SAPI Manager to be used by this control.
		''' </summary>
		<Browsable(True), Category(DESIGNER_CATEGORY)> _
		Public Property SapiManager() As SapiManager
			Get
				Return _sapiManager
			End Get
			Set(ByVal value As SapiManager)
				_sapiManager = value

				If (Not Me.DesignMode) AndAlso Not _sapiManager Is Nothing Then
					AddHandler _sapiManager.SpeechRecognized, AddressOf sapi_SpeechRecognized
				End If
			End Set
		End Property

		#End Region ' Properties

		#Region "Event Handlers"

		Private Sub btnClear_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnClear.Click
			OnClear()
		End Sub

		#End Region ' Event Handlers

		#Region "Private"

		Private Sub OnClear()
			textBoxDictation.Text = String.Empty
		End Sub

		Private Sub sapi_SpeechRecognized(ByVal text As String)
			textBoxDictation.Text += text
		End Sub


		#End Region ' Private
	End Class
End Namespace